//C9:9.9:static.cpp --using a static local variable
#include <iostream>
// constants
const int ArSize = 10;
// function prototype
void strcount(const char *str);

int main(void)
{
    using namespace std;
    char intput[ArSize];
    char next;

    cout << "Enter a line:\n";
    cin.get(intput, ArSize);
    while(cin)
    {
        cin.get(next);
        while(next != '\n')    // string didn't fit
        {
            cin.get(next);    // dispose of remainder
        }

        strcount(intput);
        cout << "Enter next line (empty line to quit):\n";
        cin.get(intput, ArSize);
    }
    cout << "Bye\n";
    return 0;
}

void strcount(const char *str)
{
    using namespace std;
    static int total = 0;    // static local variable
    int count = 0;           // automatic local variable

    cout << "\"" << str << "\" contains ";
    while(*str++)    //go to end of string
    {
        count++;
    }
    total += count;
    cout << count << " characters\n";
    cout << total << " characters total\n";
}